@echo off

rem * This script creates a Python EXE and bundle the source files with it.

rem * Quietly get rid of all the old files in the EXE's distribution folder.
rem * This action is meant to aid py2exe script tweaking.
if exist MegaMariX\ rmdir /S /Q MegaMariX

rem * Compile the binary. See setup.py for specifics.
python setup.py py2exe

rem * Create the directory for the source files.
rem * Otherwise xcopy will not know how to copy without asking.
mkdir MegaMariX\source\engine\sound_handler

rem * Copy all of the source files into the source folder.
rem * If the directory is not there, it is made automatically.
rem * In Vista and above, the files are verified after being copied. (/V)
rem * Copying will attempt to continue even during errors. (/C)
for %%D in (. engine\. engine\sound_handler\.) do (
	xcopy "%%D" "MegaMariX\source\%%D" /V /C /EXCLUDE:source_exclusions.txt
)

rem * Create the EXE's res folders.
mkdir MegaMariX\res\bullets
mkdir MegaMariX\res\snd
mkdir MegaMariX\res\special
mkdir MegaMariX\res\sprites
mkdir MegaMariX\res\stage
mkdir MegaMariX\res\tiles

rem * Copy all of the resources into the EXE's res folder.
rem * In Vista and above, the files are verified after being copied. (/V)
rem * Copying will attempt to continue even during errors. (/C)
for %%D in (
	res\bullets\. res\snd\. res\special\. res\sprites\. res\stage\. res\tiles\.
) do (
	xcopy "%%D" "MegaMariX\%%D" /V /C /EXCLUDE:source_exclusions.txt
)

rem * Copy specific files to the EXE's directory.
rem * In Vista and above, they are verified after being copied. (/V)
copy /V licence.txt MegaMariX
copy /V COPYING MegaMariX
copy /V README MegaMariX

rem * Quietly get rid of all the old files in the build folder.
rmdir /S /Q build

rem * Pause to see the exit codes.
pause
@echo on
